<template>
    <div class="cantainer">
        <div class="screen" ref="screen">
            <Top />
            <div class="bottom">
                <div class="bomleft">
                    <Tourist class="tourist" />
                    <Sex class="sex" />
                    <Age class="age" />
                </div>
                <div class="bomcenter">
                    <Mapscreen class="mapscreencs" />
                    <Line  class="linescreencs" />
                </div>
                <div class="bomright">
                    <Rank class="rankcs"/>
                    <Year class="yearcs"/>
                    <Counter class="countercs"/>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import Top from './childer/top.vue'
import Age from './age/index.vue'
import Sex from './sex/index.vue'
import Tourist from './tourist/index.vue'

import Mapscreen from './map/index.vue'
import Line from './line/index.vue'

import Year from './year/index.vue'
import Rank from './rank/index.vue'
import Counter from './counter/index.vue'
let screen = ref(null)
onMounted(() => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
function getScale(w = 1920, h = 1080) {
    const ww = window.innerWidth / w;
    const wh = window.innerHeight / h;
    return ww < wh ? ww : wh;
}
window.onresize = () => {
    console.log(222);
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`

}
onUnmounted(() => {
    // 组件卸载时，移除监听事件
    window.onresize = null
})
</script>
<style scoped lang="scss">
.cantainer {
    width: 100vw;
    height: 100vh;
    background-image: url('@/assets/image/screen/bg.png');
    background-size: cover;

    .screen {
        position: fixed;
        left: 50%;
        top: 50%;
        width: 1920px;
        height: 1080px;
        transform: scale(1);
        transform-origin: left top;
    }
}

.bottom {
    display: flex;
    height: 100%;

    .bomleft {
        flex: 1;
        display: flex;
        flex-direction: column;

        .tourist {
            flex: 1;
        }

        .age {
            flex: 1;
        }

        .sex {
            flex: 1;
        }
    }

    .bomcenter {
        flex: 2;
        margin: 0 20px;
        .linescreencs{
            height: 300px;
          
        }
        .mapscreencs{
            height: calc(100% - 300px);
            // flex: 1;
            // background-color: red;
        }
    }

    .bomright {
        display: flex;
        flex: 1;
        flex-direction: column;
        .rankcs{
            flex: 1;
        }   
        .yearcs{
            flex: 1;
        }
        .countercs{
            flex: 1;
            background: url('@/assets/image/screen/agecb.png') no-repeat;
    background-size: 100% 100%;
        }
    }
}

</style>